<template>
	<view class="w_h_100 ">
		<view class="head" v-if="data.length>0&&!loading">

			<view class="second" v-for="(item,index) in data" :key="index">
				<image src="../../static/bgs.png" style="width: 100%;position: absolute;z-index: 1;" class="img">
				</image>
				<view class="padding" style="z-index:999;position: absolute;">
					<view class="">
						<view class="type d_f " style="justify-content: space-between;">
							<view class="">
								{{item.pro_type}}
							</view>
								
							<image src="../../static/watch.png" style="width: 211rpx;height: 39rpx;"
								@tap="changex(item.quan_type)" v-if="item.status=='已付款'"></image>
						</view>
					</view>
					<view class="types d_f j_c_s_b">
						<view class="">
							订单金额：
						</view>
						<view class="money">
							￥{{item.payMoney}}
						</view>
					</view>
					<view class="types d_f j_c_s_b">
						<view class="">
							创建时间：
						</view>
						<view class="">
							{{item.createtime}}
						</view>
					</view>
					<view class="types d_f j_c_s_b">
						<view class="">订单状态：</view>

						<view class="" v-if="item.status=='失效退款'" style="color: #518BF9 ;">
							{{item.status}}
						</view>
						<view class="" v-if="item.status=='未付款'" style="color: #FF343E ;">
							{{item.status}}
						</view>
						<view class="" v-if="item.status=='已付款'">{{item.status}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bottom">

		</view>
		<empty-state :loading="loading" text=' ' class="w_h_100" :img='img' :total='data.length'></empty-state>

	</view>
</template>

<script>
	import {
		getBuyOrder
	} from '../../api/index.js'
	import moment from '../../utils/moment.js'
	export default {
		data() {
			return {
				openid: "",
				data: [],
				loading: true,
				img: '../../static/wudingdan.png'
			}
		},
		components: {

		},
		onLoad() {

		},
		onShow() {
			this.openid = uni.getStorageSync('openid')
			this.getData()

		},
		methods: {
			changex(e) {
				console.log(e)
				if (e == 1) {
					uni.navigateTo({
						url: '/pages/lijianjin/lijianjin'
					})
				} else if (e == 2) {
					uni.navigateTo({
						url: '/pages/myyouhui/myyouhui?curement=6'
					})
				}
			},
			getData() {
				this.loading = true
				getBuyOrder({
					openid: this.openid,
					pages: 100
				}).then((res) => {
					console.log(res)
					this.data = res.data
					for (var i in this.data) {
						this.data[i].createtime = moment(this.data[i].createtime * 1000).format("YYYY.MM.DD")
						if (this.data[i].pro_type == 1) {
							this.data[i].pro_type = '10期10元话费券-电商'
						} else if (this.data[i].pro_type == 2) {
							this.data[i].pro_type = '12期10元话费券90'
						} else if (this.data[i].pro_type == 3) {
			 			this.data[i].pro_type = '12期10元充电券88'
						} else if (this.data[i].pro_type == 4) {
							this.data[i].pro_type = '12期10元充电券'
						}
						if (this.data[i].status == 0) {

							this.data[i].status = '未付款'
						} else if (this.data[i].status == 1) {
							this.data[i].status = '已付款'
						} else if (this.data[i].status == 2) {
							this.data[i].status = '失效退款'
						}

					}
					this.loading = false
				}).catch(err => {
				 this.loading = false
				})
			}

		},
		watch: {

		},
		computed: {

		}
	}
</script>

<style scoped lang='scss'>
	.second {
		position: relative;
		height: 250rpx;
		margin-top: 25rpx;
	}

	.box {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100vh;
	}

	.type {
		font-size: 26rpx;
		font-weight: bold;
		color: #1A1A1A;
	}

	.head {
		padding: 20rpx;
	}

	.padding {
		padding: 28rpx 35rpx 23rpx 35rpx;
		width: 100%;
	}

	.img {
		background-size: 100% 100%;
		height: 100%;
	}

	.types {
		margin-top: 24rpx;
		font-size: 24rpx;
		color: #666666;
	}

	.money {

		font-size: 24rpx;

		font-weight: bold;
		color: #999999;
	}

	.bottom {
		height: 32rpx;
	}
</style>
